﻿using System;
using System.Drawing;
using System.Text;

namespace dotHTML.HTML {
    /// <summary>
    /// Represents a horizontal rule.
    /// </summary>
    [Serializable]
    [Standalone]
    public class Hr : Element {
        /// <summary>
        /// Defines the alignment for a horizontal rule.
        /// </summary>
        public enum Alignment {
            /// <summary>
            /// The horizontal rule is aligned to the left of the page.
            /// </summary>
            Left,
            /// <summary>
            /// The horizontal rule is aligned to the right of the page.
            /// </summary>
            Right,
            /// <summary>
            /// The horizontal rule is aligned to the center of the page.
            /// </summary>
            Center
        }

        private Alignment? _align;
        private Color? _color;
        private bool _noshade;
        private int? _size;
        private string _width;

        /// <summary>
        /// Determines the alignment of this horizontal rule.
        /// </summary>
        [Obsolete("Deprecated in HTML4 - use CSS instead.")]
        public Alignment? Align {
            get { return _align; }
            set { _align = value; }
        }

        /// <summary>
        /// Determines the color of this horizontal rule.
        /// </summary>
        [Obsolete("Non-standard. Use CSS instead.")]
        public Color? Color {
            get { return _color; }
            set { _color = value; }
        }

        /// <summary>
        /// Determines whether or not this horizontal rule should be shaded.
        /// </summary>
        [Obsolete("Deprecated in HTML4 - use CSS instead.")] 
        public bool NoShade {
            get { return _noshade; }
            set { _noshade = value; }
        }

        /// <summary>
        /// Determines the height (in pixels) of this horizontal rule.
        /// </summary>
        [Obsolete("Deprecated in HTML4 - use CSS instead.")]
        public int? Size {
            get { return _size; }
            set { _size = value; }
        }

        /// <summary>
        /// Gets the width of this horizontal rule, either in pixels or as a
        /// percentage.
        /// </summary>
        /// <remarks>This is implemented as a string so that the user can
        /// determine the unit type - pixels, percentage, etc.</remarks>
        [Obsolete("Deprecated in HTML4 - use CSS instead.")]
        public string Width {
            get { return _width; }
            set { _width = value; }
        }

        /// <summary>
        /// Gets a formatted string of all local attributes of this element
        /// (not including the base attributes).
        /// </summary>
        /// <param name="sb">The StringBuilder to write this element's
        /// attribute data to.</param>
        protected override void WriteLocalAttributes(StringBuilder sb) {
            AttributeWriter.Write(sb, _align, "align", true);
            AttributeWriter.Write(sb, _color, "color");
            AttributeWriter.Write(sb, _noshade, "noshade");
            AttributeWriter.Write(sb, _size, "size");
            AttributeWriter.Write(sb, _width, "width");
        }
    }
}
